package sxkyxt.kjyxgs.cn.ishop_gather_uploading_android;

import android.content.Context;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;
import android.widget.TextView;

import java.util.List;

/**
 * Create by 月 on 2017/3/31.
 */
public class Array_Adapter extends BaseAdapter {
    private static final String TAG = "Array_Adapter";
    private List<GoodStype.ExtendBean.GoodsTypesBean> mList;
    private Context mContext;


    public Array_Adapter(List<GoodStype.ExtendBean.GoodsTypesBean> mList, Context mContext) {
        this.mList = mList;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.simple_spinner_item1, null);
            viewHolder = new ViewHolder();
            this.initView(convertView, viewHolder);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.mText1.setText(mList.get(position).getGtname());
        viewHolder.textView_ID.setText(String.valueOf(mList.get(position).getGtparentid()));

        return convertView;
    }

    private void initView(@NonNull final View itemView, ViewHolder viewHolder) {
        viewHolder.mText1 = (CheckedTextView) itemView.findViewById(R.id.spinner_text1);
        viewHolder.textView_ID = (TextView) itemView.findViewById(R.id.spinner_text1_id);
    }

    class ViewHolder {
        private CheckedTextView mText1;
        private TextView textView_ID;
    }
}
